package cn.fotoit.product.system.entity;

import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import org.hibernate.annotations.*;

import javax.persistence.*;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.io.Serializable;
import java.util.Date;

/**
 * 菜单资源
 */
@Entity
@Table(name = "system_user_permission")
@Data
@SQLDelete(sql = "update system_user_Permission set deleted = true where id = ?")
@Where(clause = "deleted = false")
public class Permission implements Serializable {
    //菜单id
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Integer id;

    //菜单名字(名)
    @Column(unique = true, length = 50, nullable = false)
    private String name;

    //表示资源名  system_user_add
    @Column(nullable = false)
    private String permissionKey;

    //菜单描述
    @Column(nullable = false)
    private String remark;

    @CreationTimestamp
    @Column(updatable = false)
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date createTime;

    @UpdateTimestamp
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date updateTime;

    private String url;

    @ColumnDefault(value = "false")
    private Boolean deleted;

    //是否可以被修改 （默认不可以被修改）
    @ColumnDefault(value = "false")
    private Boolean canChange;

    public Permission() {
    }


}
